#pragma once
#include <iostream>
#include <list>

class MyElement{
public:
	virtual void eat() = 0;
}; 

class Apple : public MyElement{
public:
	void eat(){
		std::cout << "吃苹果！" << std::endl;
	}
}; 


class Banana : public MyElement{
public:
	void eat(){
		std::cout << "吃香蕉！" << std::endl;
	}
};

class Pear : public MyElement{
public:
	void eat(){
		std::cout << "吃梨子！" << std::endl;
	}
};


class Plate : public MyElement{
public:
	void add(MyElement *element){
		ls.push_back(element);
	}
	
	void remove(MyElement *element){
		ls.remove(element);
	}
	
	void eat(){
		for(auto i : ls){
			i->eat();
		}
	}
private:
	std::list<MyElement*> ls;
}; 